<?php
require_once 'index1.php';
require_once 'class/admin.php';


    if(isset($_REQUEST['attempt'])&isset($_REQUEST['email'])&isset($_REQUEST['pw'])){
        $email = $_REQUEST['email'];
        $pw = sha1($_REQUEST['pw']);
        
        $admin = new admin($email, $pw);
        
        if($admin->getLoginState()){
            echo "<br>-------login state is good";
            session_start();
            $_SESSION['admin']=$admin;
            $name = $admin->getName();
            echo $name;
            header("refresh:5; url=http://localhost:8080/admin.php");
        }else{
            echo "<br>-------login state is bad";
            header("refresh:2; url=http://localhost:8080/");
        }
        
        
    }else{
            echo "<br>-------login state is bad";
            header("refresh:2; url=http://localhost:8080/");
        }
    
require_once 'index2.php';
?>
    

